package obecto.tween
{
	import flash.utils.Dictionary;
	import flash.utils.getTimer;

	public class TimeTween extends AbstractTween
	{
		private var _lastTimer : Number;
		
		public function TimeTween(target:Object, tweenedProperties : Dictionary)
		{
			super(target, tweenedProperties);
			
			_lastTimer = getTimer();
		}
		
		override protected function increaseDurationElapsed() : void
		{
			var currentTimer : Number = getTimer();
		
			_durationElapsed += (currentTimer - _lastTimer) / 1000;
			_lastTimer = currentTimer;
			
			if(durationElapsed > duration)
			{
				_durationElapsed = duration;
			}
		}
	}
}